const Joi = require('joi')

// auth模块验证规则 
// 新增
const authAddSchema = Joi.object({
    pid: Joi.number(),
    name: Joi.string().min(1).max(30).required(),
    namecn: Joi.string().min(1).max(30).required(),
    level: Joi.number().required(),
    path: Joi.string().min(1).max(500),
    state: Joi.boolean()
})

// 更新 
const authUpdateSchema = Joi.object({
    id: Joi.number(),
    pid: Joi.number(),
    name: Joi.string().min(1).max(30),
    namecn: Joi.string().min(1).max(30),
    level: Joi.number(),
    path: Joi.string().min(1).max(500),
    state: Joi.boolean()
})

// 更新权限树 
const authTreeUpdateSchema = Joi.object({
    id: Joi.number(),
    pid: Joi.number(),
    name: Joi.string().min(1).max(30).required(),
    namecn: Joi.string().min(1).max(30).required(),
    level: Joi.number().required(),
    path: Joi.string().min(1).max(500),
    state: Joi.boolean(),
    children: Joi.array() 
})

// 分页查询 
const authListSchema = Joi.object({
    pageSize: Joi.number(),
    currentPage: Joi.number(),
    where: Joi.object(),
    sort: Joi.object() 
})

// 删除  
const authDeleteSchema = Joi.object({
    ids: Joi.array() 
})

exports.authAdd = authAddSchema 
exports.authList = authListSchema 
exports.authDelete = authDeleteSchema 
exports.authTreeUpdate = authTreeUpdateSchema 
exports.authUpdate = authUpdateSchema 
